package com.cy.aircompressor.main.home.fragment.provider;

import android.graphics.Color;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;

import com.cy.aircompressor.R;
import com.cy.aircompressor.databinding.ItemWarningMsgBinding;
import com.cy.aircompressor.entity.warning.WarningMsg;
import com.drug.lib.view.recycptr.ItemViewBinder;
import com.net.model.base.BaseBindViewHolder;

public class WarningMsgProvider extends ItemViewBinder<WarningMsg, WarningMsgProvider.ViewHolder> {
    @NonNull
    @Override
    protected ViewHolder onCreateViewHolder(@NonNull LayoutInflater inflater, @NonNull ViewGroup parent) {
        return new ViewHolder(ItemWarningMsgBinding.inflate(inflater, parent, false));
    }

    @Override
    protected void onBindViewHolder(@NonNull ViewHolder holder, @NonNull WarningMsg entity) {
        holder.mBinding.airName.setText(entity.getCompressorName() + "-" + entity.getCompressorPartDesc());
        holder.mBinding.occurrenceTime.setText(entity.getCreateTime());
        holder.mBinding.describe.setText(entity.getAlarmRules());
        holder.mBinding.readStatus.setText(entity.getStatus() == 1 ? "已处理" : "未处理");
//        holder.mBinding.readStatus.setTextColor(Color.parseColor(entity.getStatus() == 1 ? "#15CB22" : "#F04538"));
        holder.mBinding.readFlag.getDelegate().setBackgroundColor(Color.parseColor(entity.getStatus() == 1 ? "#bae7ff" : "#FF1414"));


        holder.itemView.setBackground(ContextCompat.getDrawable(holder.itemView.getContext(), (entity.isSelect() ?
                R.drawable.backgroud_select_status_draw : R.drawable.backgroud_deep_shallow_draw)));
    }

    public class ViewHolder extends BaseBindViewHolder<ItemWarningMsgBinding> {

        protected ViewHolder(ItemWarningMsgBinding itemView) {
            super(itemView);
        }
    }


}
